package com.songcha.module_bookreader.ui.adapter

import android.graphics.Color
import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.songcha.module_bookreader.R
import com.songcha.library_business.bean.book.BookChapterCatalogBean
import com.songcha.library_common.util.ColorUtil


class BookSlideCatalogAdapter(list:MutableList<BookChapterCatalogBean.DataBean>, var isDark: Boolean):BaseQuickAdapter<BookChapterCatalogBean.DataBean,BaseViewHolder>(R.layout.bookreader_item_slide_catalog,list) {

    fun switchMode(isDark:Boolean){
        this.isDark=isDark
        notifyDataSetChanged()
    }

    override fun convert(holder: BaseViewHolder, item: BookChapterCatalogBean.DataBean) {
        holder.getView<TextView>(R.id.bookreader_tv_chapter).apply {
            text=item.chapterTitle
            if(isDark){
                setTextColor(Color.WHITE)
            }else{
                setTextColor(ColorUtil.getResourceColor(context,com.songcha.library_common.R.color.text_color2))
            }
        }

        holder.getView<View>(R.id.bookreader_line).apply {
            if(isDark){
                setBackgroundColor(Color.WHITE)
            }else{
                setBackgroundColor(Color.parseColor("#A39D8A"))
            }
        }


    }
}